home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 8 / 008.d81 / pps #18 < prev    next >
Text File  |  2022-08-26  |  3KB  |  142 lines

  1.  
  2.  PEEKs, POKEs, and SYSes -- Part 18
  3.  
  4.  
  5.            by Jimmy Weiler
  6.  
  7.  
  8.  
  9.  
  10.   Next, we have to tell VIC that the
  11.  
  12. sprite we have defined can be found
  13.  
  14. at memory location 832.  At the same
  15.  
  16. time, we will tell VIC that it is
  17.  
  18. sprite number zero.
  19.  
  20.  
  21.   As far as VIC is concerned, memory
  22.  
  23. is divided into 64-byte pages, each
  24.  
  25. one capable of holding one sprite.
  26.  
  27. Memory location zero is sprite page
  28.  
  29. 0, 64 is sprite page 1, 128 is sprite
  30.  
  31. page 3, etc.  Our umbrella sprite is
  32.  
  33. at memory location 832 which is sprite
  34.  
  35. page 13 (832/64 = 13).
  36.  
  37.  
  38.   VIC can keep track of eight sprites
  39.  
  40. at a time.  The sprites are numbered
  41.  
  42. 0 to 7.  Memory locations 2040 to 2047
  43.  
  44. tell VIC where, in terms of sprite
  45.  
  46. pages, each of the eight sprite image
  47.  
  48. blocks is located in memory.  To tell
  49.  
  50. VIC that sprite 0 is located in memory
  51.  
  52. at address 832, you POKE 2040,13.
  53.  
  54.  
  55. 120 POKE 2040,13
  56.  
  57.  
  58.   Now VIC knows where to find the
  59.  
  60. sprite image, but doesn't know where
  61.  
  62. to DRAW it.  VIC finds out where we
  63.  
  64. want our sprites drawn by checking
  65.  
  66. memory locations 53248 to 53264.
  67.  
  68. (That's V + 0 to V + 16, for those of
  69.  
  70. you following that convention I told
  71.  
  72. you about earlier.)
  73.  
  74. V+ 0    sprite 0 horizontal position
  75. V+ 1    sprite 0 vertical   position
  76. V+ 2    sprite 1 horizontal position
  77. V+ 3    sprite 1 vertical   position
  78. V+ 4    sprite 2 horizontal position
  79. V+ 5    sprite 2 vertical   position
  80. V+ 6    sprite 3 horizontal position
  81. V+ 7    sprite 3 vertical   position
  82. V+ 8    sprite 4 horizontal position
  83. V+ 9    sprite 4 vertical   position
  84. V+10    sprite 5 horizontal position
  85. V+11    sprite 5 vertical   position
  86. V+12    sprite 6 horizontal position
  87. V+13    sprite 6 vertical   position
  88. V+14    sprite 7 horizontal position
  89. V+15    sprite 7 vertical   position
  90. V+16    sprite 0-7 horizontal hi-byte
  91.  
  92.  
  93.   Let's just talk about the positon of
  94.  
  95. sprite 0.  We'll put it at the top of
  96.  
  97. the screen, about in the middle.
  98.  
  99.  
  100. 130 V = 53248
  101. 140 POKE V+0,180
  102. 150 POKE V+1,50
  103. 160 POKE V+16,PEEK(V+16)AND254
  104.  
  105.  
  106.   Line 160 makes sure that our sprite
  107.  
  108. appears in the middle of the screen
  109.  
  110. and not somewhere off to the right
  111.  
  112. where we couldn't see it.  Each bit
  113.  
  114. set in V+16 tells VIC to add 256 to
  115.  
  116. the horizontal position of the sprite
  117.  
  118. corresponding to that bit.  We AND
  119.  
  120. that location with 254 to prevent any
  121.  
  122. change in the horizontal positions of
  123.  
  124. the other seven sprites (#1-7, which
  125.  
  126. are represented by bits 1-7).
  127.  
  128.  
  129.   Note well that sprites can be placed
  130.  
  131. off the edge of the visible screen.
  132.  
  133. The viewing area is from vertical
  134.  
  135. position 50 to vertical position 250,
  136.  
  137. and from horizontal 24 to horizontal
  138.  
  139. 256+65.
  140.  
  141. -------- Continued in Part 19 --------
  142.